//Wednesday, September 14, 2011 14:52 CDT
import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;
import java.awt.geom.*;

public class LargestSubsequence
{
	public String getLargest(String s)
	{
		int N = s.length();
		int[] pos = new int[N];
		for (int i = 0; i < N; i++) {
			pos[i] = i;
		}
		int mmax = -1;
		char c = 96;
		for (int i = 0; i < N; i++) {
			if (c < s.charAt(i)) {
				mmax = i;
				c = s.charAt(i);
			}
			char ch = 'a';
			for (int j = N - 1; j > i; j--) {
				if (s.charAt(i) >= s.charAt(j) && ch <= s.charAt(j)) {
					pos[i] = j;
					ch = s.charAt(j);
				}
			}
		}
		for (int i = 0; i < N; i++) {
			System.out.print(pos[i]);
			System.out.print(", ");
		}
		System.out.println();
		String ret = "";
		for (; mmax != pos[mmax];) {
			ret += s.charAt(mmax);
			mmax = pos[mmax];
		}
		ret += s.charAt(pos[mmax]);
		return ret;
	}
}
//Powered by [KawigiEdit] 2.0!
